import org.example.all.App;

import java.util.Arrays;
import java.util.TreeSet;


public class Solution1 {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param str string字符串 
     * @return string字符串一维数组
     */

    public static String[] match (String str) {
        // write code here
        char[] chars = str.toCharArray();
        TreeSet<String> strings = new TreeSet<>();
        char temp = chars[0];
        int count = 1;
        //最大连续数
        int maxCount = 0;
        for (int i = 1; i < chars.length; i++) {
            if (chars[i] == temp) {
                count++;
                continue;
            }
            maxCount = Math.max(maxCount, count);
            count = 1;
            temp = chars[i];
        }
        //最后一个字符
        maxCount = Math.max(maxCount, count);

        temp = chars[0];
        count = 1;
        for (int i = 1; i < chars.length; i++) {
            if (chars[i] == temp) {
                count++;
                continue;
            }
            if (count == maxCount) {
                //入选
                strings.add(String.valueOf(temp));
            }
            count = 1;
            temp = chars[i];
        }
        if (count == maxCount) {
            //入选
            strings.add(String.valueOf(temp));
        }
        return strings.toArray(new String[0]);
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(match("abc")));
    }
}